home *** CD-ROM | disk | FTP | other *** search
- /* f d o p e n
- *
- * Open a stream and associate it with a file descriptor. The
- * file descriptor would typically have been obtained from either
- * a call to open(), dup(), creat() or pipe(). The type of stream
- * (read, write or append) must agree with the mode of the open
- * file.
- *
- * The function returns a pointer to the stream on success and
- * NULL on failure.
- *
- * Patchlevel 1.0
- *
- * Edit History:
- */
-
- #include "stdiolib.h"
-
- /*LINTLIBRARY*/
-
- FILE *fdopen(fd, mode)
-
- int fd; /* channel */
- CONST char *mode; /* mode to open */
-
- {
- FILE **sp; /* slot in table */
- short flags; /* flag settings */
-
- return (sp = _slot((FILE *) NULL)) == NULL ||
- fd != _fopen((CONST char *) NULL, mode, fd, &flags)
- ? NULL
- : (*sp = _file((FILE *) NULL, fd, flags));
- }
-